Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: note url string must be static #7508

Merged
merged 1 commit into from
Mar 29, 2022
Merged

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Mar 29, 2022

Description

Closes #5558

Additional context

Something I've been thinking about is if we can replace import.meta.url as self.location.href everywhere to avoid issues like this, similar to #7464. This could be done in esbuild if the target is a browser, and it might help #5270 too.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy added the documentation Improvements or additions to documentation label Mar 29, 2022
@patak-dev patak-dev merged commit b7cc0dc into vitejs:main Mar 29, 2022
@patak-dev
Copy link
Member

Something I've been thinking about is if we can replace import.meta.url as self.location.href everywhere to avoid issues like this, similar to #7464. This could be done in esbuild if the target is a browser, and it might help #5270 too.

Maybe the best is to send a PR for this so we can discuss it there. Would this only be replaced depending on the target for example?

@bluwy
Copy link
Member Author

bluwy commented Mar 29, 2022

Was thinking that esbuild could use the platform option to replace that, since self.location.href would always exist in the browser, and also replace conditionally conditionally depending on the target. Haven't thought deeply about it, but I might try to send a PR to esbuild/Vite one day.

@bluwy bluwy deleted the docs-url-static branch March 29, 2022 07:21
@zhangyuang
Copy link
Contributor

zhangyuang commented Jun 1, 2022

Now, wasm-pack which will build WASM with JavaScript glue layer code contains input = new URL('xxx.wasm', import.meta.url); will throw error in Vite.

One of the solutions is set optimizeDeps.exclude to exclude third party module.

Even if set build.target to es2020 error will be retained, because Vite only process .js file to node_modules/.vite but not .wasm file cause glue layer code cannot find the correct path

@patak-dev
Copy link
Member

@zhangyuang would you open a new issue with a minimal reproduction? Thanks!

@zhangyuang
Copy link
Contributor

ok

@zhangyuang
Copy link
Contributor

#8427

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The production environment uses new URL(src, import.meta.url) to report an error
3 participants